<?php if (isset($_COOKIE['import_scheduler_data'])) {
	$import_scheduler_data = get_json_cookie('import_scheduler_data');
}?>

<?php if ($init_modal == TRUE || isset($import_scheduler_data)):?>

<?php if ($init_modal == TRUE || $import_scheduler_data['task'] == 'upload'):?>
<script>
$(function() {
	$('#dropbox').html5Uploader({
		postUrl: upload_url,
		onClientLoad: function(e, file) {
			
		},
		onServerLoadStart: function(e, file) {
			showProgressBar();
			$('.upload').find('.bar').css({ 'width': '0%' });
		},
		onServerProgress: function(e, file) {
			if(e.lengthComputable) {
				var percentComplete = (e.loaded / e.total) * 100;
				$('.upload').find('.bar').css({ 'width': percentComplete + '%' });
			}
		},
		onServerLoad: function(e, file) {
			$('.upload').find('.bar').css({ 'width': '100%' });
		},
		onSuccess: function(e, file) {
			setTimeout('hideProgressBar();load_import_scheduler_modal();', 1000);
		}
	});
});
</script>
<div class="upload">
	<div id="dropbox" class="droparea">
		<div class="instructions text-info">Please Drag an <strong>Excel</strong> file here</div>
		<div class="progress progress-info progress-striped active" style="visibility: hidden;">
			<div class="bar" style="width: 0%;"></div>
		</div>
	</div>
</div>

<?php if ($init_modal == FALSE):?>
<?php if ($import_scheduler_data['progress'] == 100):?>
<button class="btn btn-mini btn-success btn-block" type="button" id="import_scheduler_generate" style="margin-top: 10px;">Generate Flights by Just Uploaded File - <?php $import_scheduler_data = get_json_cookie('import_scheduler_data'); echo $import_scheduler_data['uploadFileName'];?></button>
<?php endif;?>
<?php endif;?>

<?php elseif ($import_scheduler_data['task'] == 'generate'):?>
<?php if ($import_scheduler_data['progress'] == 0):?>
<script src="./../../plugin/xmlhttprequest/XMLHttpRequest.js"></script>
<div class="generate">
	<div class="text-info" id="progress_text"><strong>Initializing...</strong></div>
	<div class="progress progress-info progress-striped active">
		<div class="bar" style="width: 0%;"></div>
	</div>
</div>
<?php elseif ($import_scheduler_data['progress'] == 100):?>
<script>
setTimeout('window.location.reload();', 2000);
</script>
<h4 class="text-success">You have succeeded in importing scheduler.</h4>
<small class="muted">The Page will be reloaded immediately!</small>
<?php endif;?>
<?php endif;?>

<?php endif;?>


